/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

#ifndef Scenic_Renderer_Image_h
#define Scenic_Renderer_Image_h


#include "Resource.h"


namespace Scenic 
{ 
namespace Renderer
{

class Texture;

struct ImageBlock
{
	Texture *texture;
	int x;
	int y;
	int width;
	int height;
	float maxS;
	float maxT;
};

class Image : public Resource
{
	ImageBlock *blocks;
	int numCols;
	int numRows;
public:
	int width;
	int height;
	Format format;
	int options;

	Image();
	~Image();

	int getNumCols() { return numCols; }
	int getNumRows() { return numRows; }
	ImageBlock *getBlock(int row, int col);

	bool create(int width, int height, Format format, int options = 0);
	void free(bool isAsync = false);
	void write(int x, int y, int width, int height, char *data, int pitch, Scenic::Renderer::Format format);
	void read(int x, int y, int width, int height, char *data, int pitch, Scenic::Renderer::Format format);
	bool contentsLost();

	static Image *get(int id);
private:
	void updateJavaObject();
};


}
}

#endif
